import request from '@/api/request'

interface MemberLevelData {
  id?: string
  name: string
  level: number
  description?: string
}

interface MemberLevelListParams {
  page?: number
  pageSize?: number
  name?: string
}

interface MemberLevelDetailParams {
  id: string
}

/**
 * 创建会员等级
 * @param data 等级数据
 * @returns 返回创建的等级信息
 */
export function createMemberLevel(data: Omit<MemberLevelData, 'id'>) {
  return request.post('/member-levels/create', data)
}

/**
 * 更新会员等级
 * @param data 等级数据
 * @returns 返回更新后的等级信息
 */
export function updateMemberLevel(data: MemberLevelData) {
  return request.post('/member-levels/update', data)
}

/**
 * 删除会员等级
 * @param data 删除数据
 * @returns Promise
 */
export function deleteMemberLevel(data: MemberLevelDetailParams) {
  return request.post('/member-levels/delete', data)
}

/**
 * 查询会员等级列表
 * @param params 查询参数
 * @returns 返回等级列表
 */
export function getMemberLevelList(params?: MemberLevelListParams) {
  return request.post('/member-levels/list', params || {})
}

/**
 * 查询会员等级详情
 * @param data 查询数据
 * @returns 返回等级详情
 */
export function getMemberLevelDetail(data: MemberLevelDetailParams) {
  return request.post('/member-levels/detail', data)
}

